<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%--
- Author(s): Administrator
- Date: 2018-05-21 15:04:37
- Description:
    --%>
<head>
<title>版本变更记录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="<%=request.getContextPath()%>/common/nui/nui.js"
	type="text/javascript">
	
</script>
</head>
<body style="width: 98%; height: 95%;">
	<div class="nui-panel" title="" iconCls="icon-add"
		style="width: 100%; height: 15%;" showToolbar="false"
		showFooter="true">
		<div id="form1" class="nui-form"  style="height: 100%">
			<!-- 数据实体的名称 -->
			<input class="nui-hidden" name="criteria/_entity"
				value="com.zhmy.xmgl.ZHMY_VERSION_CHANGE.ZhmyVersionChange">
			<!-- 排序字段 -->
			<input class="nui-hidden" name="criteria/_orderby[1]/_property"
				value="vcId"> <input class="nui-hidden"
				name="criteria/_orderby[1]/_sort" value="asc">
			<table id="table1" class="table" style="height: 100%">
	<tr>
                        <td class="form_label">
                            查询版本号:
                        </td>
                        <td colspan="1">
                            <input class="nui-textbox" name="criteria/_expr[1]/vcVersionNumber"/>
                            <input class="nui-hidden" name="criteria/_expr[1]/_op" value="like">
                            <input class="nui-hidden" name="criteria/_expr[1]/_likeRule" value="start">
                        </td>
                        <td class="form_label">
                            查询版本说明关键字:
                        </td>
                        <td colspan="1">
                            <input class="nui-textbox" name="criteria/_expr[2]/vcDescribe"/>
                            <input class="nui-hidden" name="criteria/_expr[2]/_op" value="like">
                            <input class="nui-hidden" name="criteria/_expr[2]/_likeRule" value="all">
                        </td>
                    
                        <td class="form_label">
                           <!--  查询项目ID: -->
                        </td>
                        <td colspan="1">
                            <input class="nui-hidden" name="criteria/_expr[3]/zhmyProject.projectId"/>
                            <input class="nui-hidden" name="criteria/_expr[3]/_op" value="=">
                        </td>
                        <td colspan="1">
                        <a class="nui-button" onclick="search()"> 查询 </a> <a
			class="nui-button" onclick="reset()"> 重置 </a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
	<!--footer-->

	<div class="nui-panel" title="版本列表" iconCls="icon-add"
		style="width: 100%; height: 85%;" showToolbar="false"
		showFooter="false">
		<div class="nui-toolbar" style="border-bottom: 0; padding: 0px;">
			<table style="width: 100%;">
				<tr>
					<td style="width: 100%;">
						<!--  <a class="nui-button" iconCls="icon-add" onclick="add()">
                                增加
                            </a> --> <a id="update" class="nui-button"
						iconCls="icon-edit" onclick="edit()"> 修改 </a> <a
						class="nui-button" iconCls="icon-remove" onclick="remove()">
							删除 </a>
					</td>
				</tr>
			</table>
		</div>
		<div class="nui-fit">
			<div id="datagrid1" dataField="zhmyversionchanges"
				class="nui-datagrid" style="width: 100%; height: 100%;"
				url="com.zhmy.xmgl.zhmyversionchangebiz.queryZhmyVersionChanges.biz.ext"
				pageSize="10" showPageInfo="true" multiSelect="true"
				onselectionchanged="selectionChanged" allowSortColumn="false" ondrawcell="addLink" >

				<div property="columns">
					<div type="indexcolumn"></div>
					<div type="checkcolumn"></div>
					<div field="vcId" headerAlign="center" allowSort="true"
						visible="false">vcId</div>
					<div field="vcVersionNumber" headerAlign="center" allowSort="true">
						版本号</div>
					<div field="zhmyProject.projectName" headerAlign="center"
						allowSort="true">项目名称</div>
					<div field="vcSourceAddress" headerAlign="center" allowSort="true">
						源代码压缩文件</div>
					<!-- <div field="vcDescribe" headerAlign="center" allowSort="true" >
                            vcDescribe
                        </div> -->
					<div field="vcFonder" headerAlign="center" allowSort="true">
						添加人</div>
					<div field="vcCtime" headerAlign="center" allowSort="true">
						添加时间</div>
					<div field="vcUtime" headerAlign="center" allowSort="true"
						visible="false">vcUtime</div>
						<div name="log" style="width:300px;" >操作</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	var projectId = "<%= request.getParameter("projectId") %>";
        	if (projectId > 0 ) {
        		$("[name$=projectId]").val(projectId);
        	}
	
		nui.parse();
		var grid = nui.get("datagrid1");

		var formData = new nui.Form("#form1").getData(false, false);
		grid.load(formData);

		//新增
		/* function add() {
		    nui.open({
		        url: "ZhmyVersionChangeForm.jsp",
		        title: "新增记录", width: 600, height: 300,
		        onload: function () {//弹出页面加载完成
		        var iframe = this.getIFrameEl();
		        var data = {pageType:"add"};//传入页面的json数据
		        iframe.contentWindow.setFormData(data);
		        },
		        ondestroy: function (action) {//弹出页面关闭前
		        grid.reload();
		    }
		    });
		} */

		//编辑
		function edit() {
			var row = grid.getSelected();
			if (row) {
				nui.open({
					url : "<%= request.getContextPath()%>/xmgl/ZhmyVersionChangeForm.jsp",
					title : "修改版本信息",
					width : 600,
					height : 300,
					onload : function() {
						var iframe = this.getIFrameEl();
						var data = {
							pageType : "edit",
							record : {
								zhmyversionchange : row
							}
						};
						//直接从页面获取，不用去后台获取
						iframe.contentWindow.setFormData(data);
					},
					ondestroy : function(action) {
						grid.reload();
					}
				});
			} else {
				nui.alert("请选中一条记录", "提示");
			}
		}
		function edit1() {
			var row = grid.getSelected();
			if (row) {
				nui.open({
					url : "<%=request.getContextPath()%>/xmgl/ZhmyVersionChange.jsp",
					title : "查看版本详细信息",
					width : 600,
					height : 350,
					onload : function() {
						var iframe = this.getIFrameEl();
						var data = {
							pageType : "edit",
							record : {
								zhmyversionchange : row
							}
						};
						//直接从页面获取，不用去后台获取
						iframe.contentWindow.setFormData(data);
					},
					ondestroy : function(action) {
						grid.reload();
					}
				});
			} else {
				nui.alert("请选中一条记录", "提示");
			}
		}

		//删除
		function remove() {
			var rows = grid.getSelecteds();
			if (rows.length > 0) {
				nui
						.confirm(
								"确定删除选中记录？",
								"系统提示",
								function(action) {
									if (action == "ok") {
										var json = nui.encode({
											zhmyversionchanges : rows
										});
										grid.loading("正在删除中,请稍等...");
										$
												.ajax({
													url : "com.zhmy.xmgl.zhmyversionchangebiz.deleteZhmyVersionChanges.biz.ext",
													type : 'POST',
													data : json,
													cache : false,
													contentType : 'text/json',
													success : function(text) {
														var returnJson = nui
																.decode(text);
														if (returnJson.exception == null) {
															grid.reload();
															nui
																	.alert(
																			"删除成功",
																			"系统提示",
																			function(
																					action) {
																			});
														} else {
															grid.unmask();
															nui.alert("删除失败",
																	"系统提示");
														}
													}
												});
									}
								});
			} else {
				nui.alert("请选中一条记录！");
			}
		}

		//重新刷新页面
		function refresh() {
			var form = new nui.Form("#form1");
			var json = form.getData(false, false);
			grid.load(json);//grid查询
			nui.get("update").enable();
		}

		//查询
		function search() {
			var form = new nui.Form("#form1");
			var json = form.getData(false, false);
			grid.load(json);//grid查询
		}

		//重置查询条件
		function reset() {
			var form = new nui.Form("#form1");//将普通form转为nui的form
			form.reset();
		}

		//enter键触发查询
		function onKeyEnter(e) {
			search();
		}

		//当选择列时
		function selectionChanged() {
			var rows = grid.getSelecteds();
			if (rows.length > 1) {
				nui.get("update").disable();
			} else {
				nui.get("update").enable();
			}
		}
		
		function addLink(e){
		
               
			if (e.column.name == "log") {
			
			    var rowline = e.row.VcId;
			    
			    
			    var style1 = "style='margin: 2px; background:#008cba; color:#fff; text-align: center; display: block; border-radius:8px; padding:4px 10px; border:none;'";
				
			    
			    var detailsButton = "<a><button "+style1+" onclick='edit1("+rowline+")'>查看</button></a>";
			
				
			    var fjsc="<a><button "+style1+"onclick='UploadFile("+e.row.vcId+")'>附件上传</button></a>";
			    e.cellHtml = detailsButton+fjsc;
			    if(e.row.vcSourceAddress!=null){
				var fjxz="<a><button "+style1+"onclick='toDownloadFile(\""+encodeURI(e.row.vcSourceAddress)+"\")'>附件下载</button></a>";
				 e.cellHtml = '<div style="width:200px;text-align:left">'+detailsButton+fjsc+fjxz+'</div>';
				}
			       
			    }
			
		}
			//上传文件
					function UploadFile(vcId) {
						nui.open({
							url: "<%= request.getContextPath() %>/xmgl/bbUploadfile.jsp?vcId="+vcId,
	                        title: "上传文件",
	                        width: 600,
	                        height: 300,
						});
					}
		
		 function toDownloadFile(attAddress) {
				          	location.href= "<%= request.getContextPath()%>/xmgl/filedownLoad.jsp?attAddress="+attAddress;
                     }
	</script>
</body>
</html>
